package com.xnyzc.lhy.order.controller.capi.user.wallet;


import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.exception.PangException;
import com.xnyzc.lhy.common.penum.EErrorCode;
import com.xnyzc.lhy.common.util.CheckUtil;
import com.xnyzc.lhy.common.util.TokenUtil;
import com.xnyzc.lhy.order.service.user.wallet.IOaCWalletService;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户钱包 前端控制器
 * </p>
 *
 * @author bin
 * @since 2019-07-18
 */
@RestController
@RequestMapping("capi/wallet")
public class OaCWalletController {

    @Autowired
    private IOaCWalletService iOaCWalletService;

    @GetMapping(value = "getWallet")
    public Rv getWallet(){
        Long userId = TokenUtil.getTokenUserId();
        String tag = TokenUtil.getTag();
        String userType = TokenUtil.getUserType();
        if (CheckUtil.objIsEmpty(tag, userType)){
            throw PangException.create(EErrorCode.missingAuthArgs);
        }
        return Rv.wrap(iOaCWalletService.getWallet(userId, tag, Integer.valueOf(userType)));
    }

    /**
     * 获取充值列表
     * @return
     */
    @GetMapping(value = "getTopUpList")
    public Rv getTopUpList(){
        String tag = TokenUtil.getTag();
        if (StringUtils.isEmpty(tag)){
            throw PangException.create(EErrorCode.missingAuthArgs);
        }
        return Rv.wrap(iOaCWalletService.getTopUpList(tag));
    }

    /**
     * 根据用户id获取公务额度以及其他信息
     * @return # 个人公务额度 部门公务额度 用车的可用时间 用车的可用车型 用车的可用地点 是否显示部门可用额度
     */
//    @ApiOperation(value = "根据用户id获取公务额度以及其他信息", notes = "根据用户id获取公务额度以及其他信息")
//    @GetMapping(value = "getOfficialAmountByUserId")
//    public Rv getOfficialAmountByUserId(){
//        long userId = TokenUtil.getTokenUserId();
//        if (userId == 0){
//            throw PangException.create(EErrorCode.tokenExpire);
//        }
//        return Rv.wrap(iOaCWalletService.getOfficialAmountByUserId(userId));
//    }
}
